﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Shared/MainPage.Master" AutoEventWireup="true" CodeBehind="ContractItemListSale.aspx.cs" Inherits="Runda.CMS.Portal.Workspace.ContractItemListSale" %>

<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" runat="server">
    <link href="../Content/global.css" rel="stylesheet" type="text/css" />
    <script src="../Content/global.js" type="text/javascript"></script>
    <link href="../Content/Menu/Menu.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function SelectInstrument() {
            var returnValue = openStdDlg("SelectContractItemInstrument.aspx?ContractID="+document.getElementById('<%=txtContractID.ClientID %>').value, "", 800, 600);
            RefreshItems();
        }

        function RefreshItems() {
            document.getElementById('<%=btnRefresh.ClientID %>').click();
        }

        function RowSelected(rowObject) {
            document.getElementById("<%=txtItemType.ClientID %>").value = rowObject.KeyValues["Type"];        
            document.getElementById("<%=txtItemID.ClientID %>").value = rowObject.KeyValues["ItemID"];
            document.getElementById("<%=btnRefreshGuaranty.ClientID %>").click();
        }

        function AddGuaranty() {
            if (document.getElementById("<%=txtItemType.ClientID %>").value != "2") {
                alert('请选择机器!');
                return;
            }
            if (document.getElementById('<%=txtItemID.ClientID %>').value == "") {
                alert('请选择机器!!');return;
            }
            var returnValue = openStdDlg("ItemGuarantyAdd.aspx?ItemID=" + document.getElementById('<%=txtItemID.ClientID %>').value, "", 600, 500);

            RefreshGuaranty();
        }

        function RefreshGuaranty() {
            if (document.getElementById('<%=txtItemID.ClientID %>').value == "") {
                alert('请选择机器!!'); return;
            }
            document.getElementById('<%=btnRefreshGuaranty.ClientID %>').click();
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphBody" runat="server">

    <rad:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <rad:AjaxSetting AjaxControlID="btnRefresh">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="gridContractItems" />
                </UpdatedControls>
            </rad:AjaxSetting>
            <rad:AjaxSetting AjaxControlID="btnRefreshGuaranty">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="gridGuaranty" />
                </UpdatedControls>
            </rad:AjaxSetting>
            <rad:AjaxSetting AjaxControlID="gridContractItems">
                <UpdatedControls>
                    <rad:AjaxUpdatedControl ControlID="txtItemID" />
                    <rad:AjaxUpdatedControl ControlID="txtItemType" />
                    <rad:AjaxUpdatedControl ControlID="gridGuaranty" />
                </UpdatedControls>
            </rad:AjaxSetting>
        </AjaxSettings>
    </rad:RadAjaxManager>
    
 <div class="area" id="areaForm" >
                    
    <div style="margin: 5px 0 5px 0">
    </div>
    <table class="mnubar" cellspacing="0" cellpadding="0" height="400px">
        <tbody>
            <tr>
                <td style="padding-left: 5px" nowrap>
                    <b>合同明细项</b>
                </td>
                <td style="padding-left: 5px">
                    <img src="../Content/Grid/separator.gif">
                </td>
                <td class="icMenu" nowrap> 
                </td>
                <td class="icMenu mnuRight" nowrap>
                     <span class="menu"  onclick="return RefreshItems();">
                            <img class="mnuBtn" src="../Images/16_L_refresh.gif"><span class="mnuBtn">刷新</span></span>
                     <span class="menu"  onclick="return SelectInstrument();" style="display:none">
                            <img class="mnuBtn" src="../Content/Grid/New_16_blue.gif"><span class="mnuBtn">选择新项</span></span>
                </td>
            </tr>
        </tbody>
    </table>
     <rad:RadGrid runat="server" ID="gridContractItems" Skin="OCM" AutoGenerateColumns="False"
         AllowSorting="True" GridLines="None" OnItemCommand="gridContractItems_ItemCommand"
         OnSortCommand="gridContractItems_SortCommand" OnItemDataBound="gridContractItems_ItemDataBound" EnableAJAX="True" 
                        EnableAJAXLoadingTemplate="True">
                        <AJAXLoadingTemplate>
                        加载中...
                        </AJAXLoadingTemplate>
        <ClientSettings EnableClientKeyValues="true">
            <Selecting AllowRowSelect="true" />
            <ClientEvents OnRowSelected="RowSelected" />
        </ClientSettings>
        <MasterTableView DataKeyNames="ItemID,Type"> 
            <Columns>
                <rad:GridBoundColumn DataField="InstrumentCode" HeaderText="编码">
                </rad:GridBoundColumn>
                <rad:GridBoundColumn DataField="InstrumentName" HeaderText="名称"></rad:GridBoundColumn>
                <rad:GridBoundColumn DataField="ItemStandard" HeaderText="规格"></rad:GridBoundColumn>
                <rad:GridBoundColumn DataField="unit" HeaderText="单位"></rad:GridBoundColumn>
                <rad:GridBoundColumn DataField="vendor" HeaderText="厂家"></rad:GridBoundColumn>
                 <rad:GridTemplateColumn HeaderText="数量">
                    <ItemTemplate>
                        <asp:TextBox ID="txtCount" runat="server" Width="40px" CssClass="input" Text='<%#Eval("Count") %>' Enabled="false"></asp:TextBox>
                     </ItemTemplate>
                </rad:GridTemplateColumn>
                   <rad:GridTemplateColumn HeaderText="销售价">
                    <ItemTemplate>
                        <asp:TextBox ID="txtPrice" runat="server" Width="40px" CssClass="input" Text='<%#Eval("Price") %>' Enabled="false"></asp:TextBox>
                     </ItemTemplate>
                </rad:GridTemplateColumn>
                <rad:GridTemplateColumn HeaderText="厂家保修年限">
                    <ItemTemplate>
                        <asp:TextBox ID="txtGuaranteeVendor" runat="server" Width="40px" CssClass="input" Text='<%#Eval("GuaranteeVendor") %>' Enabled="false"></asp:TextBox>
                    </ItemTemplate>
                </rad:GridTemplateColumn>
                <rad:GridTemplateColumn HeaderText="操作" Visible="false">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkbtnSave" runat="server" Text="保存" CommandName="save"></asp:LinkButton>
                     </ItemTemplate>
                </rad:GridTemplateColumn>
                <rad:GridButtonColumn CommandName="delete" Text="删除" Visible="false">
                </rad:GridButtonColumn>
            </Columns>
        </MasterTableView>
    </rad:RadGrid>
    <div style="border-bottom: #c2c2bf 1px solid; border-top: #969693 1px solid">
    </div>
     
    <table class="mnubar" cellspacing="0" cellpadding="0" height="400px">
        <tbody>
            <tr>
                <td style="padding-left: 5px" nowrap>
                    <b>机器保修约定</b>
                </td>
                <td style="padding-left: 5px">
                    <img src="../Content/Grid/separator.gif">
                </td>
                <td class="icMenu" nowrap>
                </td>
                <td class="icMenu mnuRight" nowrap><span class="menu"  onclick="return RefreshGuaranty();">
                            <img class="mnuBtn" src="../Images/16_L_refresh.gif"><span class="mnuBtn">刷新</span></span>
                    <span class="menu"  onclick="return AddGuaranty();" style="display:none">
                            <img class="mnuBtn" src="../Content/Grid/New_16_blue.gif"><span class="mnuBtn">新增保修约定</span></span>
                </td>
            </tr>
        </tbody>
    </table>
     
    <div style="border-bottom: #c2c2bf 1px solid; border-top: #969693 1px solid">
    </div>
    
     <rad:RadGrid runat="server" ID="gridGuaranty" Skin="OCM" AutoGenerateColumns="False" AllowSorting="True" GridLines="None" OnDeleteCommand="gridGuaranty_DeleteCommand">
        <MasterTableView DataKeyNames="GuarantyID">
            <Columns>
                <rad:GridBoundColumn DataField="startDate" HeaderText="开始时间" ItemStyle-HorizontalAlign="Left"></rad:GridBoundColumn>
                <rad:GridBoundColumn DataField="endDate" HeaderText="截止时间"></rad:GridBoundColumn>
                <rad:GridTemplateColumn HeaderText="保修类型">
                    <ItemTemplate>
                        <%#Eval("guarantyType").ToString() == "1" ? "厂家保修" : "商家保修"%>
                    </ItemTemplate>
                </rad:GridTemplateColumn>
                 <rad:GridTemplateColumn HeaderText="保修状态">
                    <ItemTemplate>
                         <%# Eval("guarantyStatus").ToString() == "0"? "非保修": "保修"%>
                    </ItemTemplate>
                </rad:GridTemplateColumn>
                <rad:GridButtonColumn CommandName="delete" Text="删除" Visible="false">
                </rad:GridButtonColumn>
            </Columns>
        </MasterTableView>
    </rad:RadGrid>
    
</div>
    <asp:HiddenField ID="txtContractID" runat="server" />
    <asp:HiddenField ID="txtItemID" runat="server" />
    <asp:HiddenField ID="txtItemType" runat="server" />
    <asp:Button ID="btnRefresh" runat="server" Text="刷新"  onclick="btnRefresh_Click" style="display:none" />
    <asp:Button ID="btnRefreshGuaranty" runat="server" Text="刷新" OnClick="btnRefreshGuaranty_Click"  style="display:none" />
</asp:Content>
